﻿namespace UnitTestInjector
{
    #region Usings

    using Exceptions;
    using System;
    using System.Collections.Generic;
    using System.Diagnostics.CodeAnalysis;

    #endregion Usings

    public class MockDependencyResolver : Dictionary<Type, object>, IDependencyResolver
    {
        [ExcludeFromCodeCoverage]
        public TDependency Resolve<TDependency>() where TDependency : class
        {
            if (!ContainsKey(typeof(TDependency))) return default(TDependency);
            var implementation = (TDependency)this[typeof(TDependency)];

            if (implementation == null) throw new DependencyNotResolvableException(typeof(TDependency));

            return implementation;
        }
    }
}